<template>
  <el-container>
    <el-main>
      <el-input v-model="filename" placeholder="Please choose file" type="file" id="file"/>
      <el-row>
        <el-button type="primary" @click="upload()">上传</el-button>
      </el-row>
    </el-main>
  </el-container>
</template>

<script lang="ts" setup>
import {ref} from "vue";
import axios from "axios";

const filename = ref()
const upload=(() =>{
  console.log(document.querySelector('#file').files[0])
  var fd = new FormData();
  fd.append("file", document.querySelector('#file').files[0]);
  axios({
    url: "/image/upload",
    method: "post",
    data: fd,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
  }).then(function (res) {
    console.log(res);
  })
})
</script>

<style scoped>

</style>